<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数的返回值</title>
</head>
<body>
    <script>
        //函数应返回一个值给调用者（非输出文本型函数）
        function a(name){
            return "WDNMD"+name;
        }
        var r = a("WDNMD");
        console.log(r);
        
        //判断两数中的最大值
        function m(num1,num2){
            if(num1>num2) return num1;
            else if(num1<num2) return num2;
            else return "equal"
        }
        console.log(m(1,20000));
        
        //找到数组中的最大值
        function m2(arr){
            max = arr[0];
            for(let i=0;i<arr.length;i++){
                max = Math.max(max,arr[i]);
            }
            return max;
        }
        console.log(m2([1,2,3,4,4,4,415,15,15,15,1,51,51]));

        //函数若有返回值，则返回return后的值，若没有return则返回undefined
    </script>
</body>
</html>